package high.concurrent.job;

import com.xxl.job.core.biz.model.ReturnT;
import com.xxl.job.core.handler.annotation.XxlJob;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import static com.xxl.job.core.biz.model.ReturnT.SUCCESS;


/**
 * 任务Handler示例（Bean模式）
 *
 * 监测product服务的商品冻结表是否有长时间存在的数据
 *
 */
@Slf4j
@Component
public class CheckProductJobHandler {

    @Autowired(required = false)
    private RabbitTemplate rabbitTemplate;

    /**
     * 过期时间 单位分钟
     */
    private static final int VERDUE_TIME=5;

    @XxlJob("checkProduct")
    public ReturnT<String> consumeMsgJobHandler(String s) throws Exception {

        log.info("进入消费定时任务..........................");

        // TODO 定时轮询product_task表是否有超过5分钟还没被删除的数据，进行订单状态检查

        return SUCCESS;
    }
}